package com.test1;

import java.io.File;
import java.util.ArrayList;

public class test1 {
    public static void main(String[] args){
        //java获取12套背景图
        ArrayList<String> bacList = new ArrayList<>();
        File bacFile = new File("D:/图片素材/Fecheiws Store/moban2");
        File[] bacFiles = bacFile.listFiles();
        for (int i = 0; i < bacFiles.length; i++) {
            File file1 = bacFiles[i];
            String fileName = file1.getName();
            String prefix = fileName.substring(fileName.lastIndexOf(".") + 1)
                    .toLowerCase();
            if ("jpg".equals(prefix) || "png".equals(prefix)
                    || "bmp".equals(prefix) || "gif".equals(prefix)) {
                bacList.add(fileName);
            }
        }

        //java获取ui图的所有图片
        File fileUi = new File("D:/图片素材/Fecheiws Store/ui");
        File[] fileUis = fileUi.listFiles();
        ArrayList<String> uiList = new ArrayList();
        for (int i = 0; i < fileUis.length; i++) {
            File file1 = fileUis[i];
            String fileName = file1.getName();
            String prefix = fileName.substring(fileName.lastIndexOf(".") + 1)
                    .toLowerCase();
            if ("jpg".equals(prefix) || "png".equals(prefix)
                    || "bmp".equals(prefix) || "gif".equals(prefix)) {
                uiList.add(fileName);
            }
        }

        //java获取框架文件里所有图片
        ArrayList<String> list = new ArrayList();
        File file = new File("D:/图片素材/Fecheiws Store/kuangjia");
        File[] files = file.listFiles();
        for (int i = 0; i < files.length; i++) {
            File file1 = files[i];
            String fileName = file1.getName();
            String prefix = fileName.substring(fileName.lastIndexOf(".") + 1)
                    .toLowerCase();
            if ("jpg".equals(prefix) || "png".equals(prefix)
                    || "bmp".equals(prefix) || "gif".equals(prefix)) {
                list.add(fileName);
            }
        }

        for (String s:
                list) {
            String[] splitStrings = s.split("_");
            String fileNameStr = splitStrings[0];
            for (String s1:
                    bacList) {
                File file11 = new File("D:\\图片素材\\Fecheiws Store\\result2\\"+fileNameStr);
                File file12 = new File("D:\\图片素材\\Fecheiws Store\\result3\\"+fileNameStr);
                if(!file11.exists()){
                    file11.mkdir();
                }
                if(!file12.exists()){
                    file12.mkdir();
                }
                String[] backStrings = s1.split("_");
                String backName = backStrings[0];

                try {
                    //pc端
                    if(backName.equals("1")){
                        ImageUtils.margeImage(50,165,550,515,"D:\\图片素材\\Fecheiws Store\\moban2\\"+s1,
                                "D:\\图片素材\\Fecheiws Store\\kuangjia\\"+s, "D:\\图片素材\\Fecheiws Store\\ui2\\1.png",
                                "D:\\图片素材\\Fecheiws Store\\result3\\"+fileNameStr+"\\"+backName+".jpg");

                        ImageUtils.margeImage(250,255,750,605,"D:\\图片素材\\Fecheiws Store\\result3\\"+fileNameStr+"\\"+backName+".jpg",
                                "D:\\图片素材\\Fecheiws Store\\kuangjia\\"+s, "D:\\图片素材\\Fecheiws Store\\ui2\\2.png",
                                "D:\\图片素材\\Fecheiws Store\\result3\\"+fileNameStr+"\\"+backName+".jpg");

                        ImageUtils.margeImage(450,345,950,695,"D:\\图片素材\\Fecheiws Store\\result3\\"+fileNameStr+"\\"+backName+".jpg",
                                "D:\\图片素材\\Fecheiws Store\\kuangjia\\"+s, "D:\\图片素材\\Fecheiws Store\\ui2\\3.png",
                                "D:\\图片素材\\Fecheiws Store\\result2\\"+fileNameStr+"\\"+backName+".jpg");
                    }
                    if(backName.equals("2")){
                        ImageUtils.margeImage(30,165,380,515,"D:\\图片素材\\Fecheiws Store\\moban2\\"+s1,
                                "D:\\图片素材\\Fecheiws Store\\kuangjia\\"+s, "D:\\图片素材\\Fecheiws Store\\ui2\\1.png",
                                "D:\\图片素材\\Fecheiws Store\\result3\\"+fileNameStr+"\\"+backName+".jpg");

                        ImageUtils.margeImage(200,255,550,605,"D:\\图片素材\\Fecheiws Store\\result3\\"+fileNameStr+"\\"+backName+".jpg",
                                "D:\\图片素材\\Fecheiws Store\\kuangjia\\"+s, "D:\\图片素材\\Fecheiws Store\\ui2\\2.png",
                                "D:\\图片素材\\Fecheiws Store\\result3\\"+fileNameStr+"\\"+backName+".jpg");

                        ImageUtils.margeImage(370,345,720,695,"D:\\图片素材\\Fecheiws Store\\result3\\"+fileNameStr+"\\"+backName+".jpg",
                                "D:\\图片素材\\Fecheiws Store\\kuangjia\\"+s, "D:\\图片素材\\Fecheiws Store\\ui2\\3.png",
                                "D:\\图片素材\\Fecheiws Store\\result2\\"+fileNameStr+"\\"+backName+".jpg");
                    }

                }catch (Exception e){

                }

            }
        }
    }

}
